package com.suxin.queue;

import java.util.Comparator;

/**
 * @author Tang
 * @classname AbstractQueue
 * @description [  ]
 * @date 2021/3/11 20:48
 */
public abstract class AbstractQueue<E> implements Queue<E>{

    private Comparator<E> comparator;

    public AbstractQueue(Comparator<E> comparator) {
        this.comparator = comparator;
    }

    public boolean less(E a,E b) {
        return comparator.compare(a,b) < 0;
    }

    public void exch(E[] e, int x, int y) {
        E temp = e[x];
        e[x] = e[y];
        e[y] = temp;
    }

}